+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
REPLICATION FILE for "Disentangling an elusive relationship"
2019-01-16
Marlene Mauk
marlene.mauk@gesis.org
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

*************************
 merging the survey data
*************************
numlabel _all, add
cd [path]

//** recoding the Afrobarometer **//
usespss .\merged-round-5-data-34-countries-2011-2013-last-update-july-2015.sav
save merged-round-5-data-34-countries-2011-2013-last-update-july-2015.dta, replace
use .\merged-round-5-data-34-countries-2011-2013-last-update-july-2015.dta /*this file needs to be created by transforming the .sav file to .dta*/

gen countrymerge = COUNTRY_ALPHA + 100
gen survey = 1
gen year = 2012
replace year = 2013 if countrymerge==101 | countrymerge==106 | countrymerge==108 | countrymerge==109 | countrymerge==112 | countrymerge==116 | countrymerge==120 | countrymerge==123 | countrymerge==124 | countrymerge==125 | countrymerge==128 | countrymerge==129 | countrymerge==132 | countrymerge==134
replace year = 2011  if countrymerge==102 | countrymerge==107 | countrymerge==113 | countrymerge==127

mvdecode Q59A Q59B Q59H Q59I, mv(-1 9 997 998)
gen trust1 = (Q59A/3)
gen trust2 = (Q59B/3)
gen trust3 = (Q59H/3)
gen trust4 = (Q59I/3)
numlabel _all, add

mvdecode Q31C Q9A Q3B Q14 Q87, mv(-1 9/998)
mvdecode Q46A, mv(-1 99)
gen auth1 = (1-((Q31C-1)/4))
gen dpe2 = Q46A/10
gen spe1 = 1-(Q9A/4) 
gen status3 = (Q3B-1)/4
gen polint = Q14/3
gen soctrust = Q87
recode Q96 (0/1=0) (2/3=1) (9/998=.) (-1=.), gen(employed)
recode Q97 (0/1=1) (2/3 = 2) (4/6 = 3) (7/9 = 4) (99/999=.) (-1=.), gen(edulevel)
recode Q98A (-1=.) (0=0) (1/2=1) (3/4=6) (5/6=2) (7/10=2) (11=6) (12/13=2) (14/15=6) (16=6) (17=6) (18/24=3) (25=6) (26=5) (27=6) (28/29=0) (30/31=2)(32/499=6)(500/501=3) (502/865=6) (900=4) (901/929=6) (930/931=3) (932/1420=6) (9995=6) (9998=.) (9999=.), gen(religion)
mvdecode Q98B, mv(-1 8 9)
gen reli = (Q98B-1)/3
recode Q101 (1=0) (2=1), gen(female)
mvdecode Q1, mv(-1 998 999)
gen age = Q1

drop COUNTRY-SupplyDemo
save afro5.dta, replace


//** recoding the Americas Barometer **//
*** merge individual country files from AmericasBarometer
use "1240357522Argentina LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "201493230Belize LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1852710534Bolivia LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "54861031Brazil LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1921596816Canada LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "420502678Chile LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1553850479Colombia LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "2054788361CostaRica LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1076064826DomRep LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1782383684Ecuador LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1126250629ElSalvador LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "2041873797Guatemala LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "389696727Guyana LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "895963730Haiti LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "42768395Honduras LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "2063856507Jamaica LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "641926122Mexico LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "860821151Nicaragua LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1012668426Panama LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1346923279Paraguay LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1347834535Peru LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "108630764Suriname LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "1496679067TrinandTob LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "241473079UnitedStates LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "878322670Uruguay LAPOP AmericasBarometer 2012 Rev1_W.dta"
append using "256579462Venezuela LAPOP AmericasBarometer 2012 Rev1_W.dta"

save AmericasBarometer_2012_Rev1_W.dta, replace
***
use .\AmericasBarometer_2012_Rev1_W.dta

gen countrymerge = pais + 200
gen survey = 2

gen trust1 = (b21a-1)/6
gen trust2 = (b13-1)/6
gen trust3 = (b18-1)/6
gen trust4 = (b12-1)/6

recode aut1 (1=0) (2=1), gen(auth1)
gen dpe2 = (n3-1)/6
gen spe1 = 1-((aoj11-1)/3)
gen polint = 1-((pol1-1)/3)
gen soctrust = 1-((it1-1)/3)
recode ocup4a (1/2=1) (3/7=0) (else=.), gen(employed)
recode ed (0=1) (1/6=2) (7/12=3) (13/18=4) (else = .), gen(edulevel)
gen status3 = 1-((idio1-1)/4)
recode q3c (4=0) (11=0) (1=1) (2=2) (3=6) (5=2) (6=1) (7=6) (10=6) (12=6) (else=.), gen(religion)
gen reli = 1-((q5b-1)/3)
recode q1 (1=0) (2=1), gen(female)
gen age = q2

drop pais
drop idnum-estratovene
save americas2012.dta, replace


//** recoding the Arab Barometer **//
use .\Arab_Barometer_Third_Wave_English_Data_Set_v1.dta

gen countrymerge = country + 300
gen survey = 3
gen year = year(date)

mvdecode q2011 q2013 q2014 q2016, mv (0 8 9)
gen trust1 = 1-((q2011-1)/3)
gen trust2 = 1-((q2013-1)/3)
gen trust3 = 1-((q2014-1)/3)
gen trust4 = 1-((q2016-1)/3)

mvdecode q5183 q105 q102a q404 q609, mv(0 8 9)
mvdecode q511, mv(94/99)
gen auth1 = (q5183-1)/3
gen dpe2 = q511/10
gen spe1 = 1-((q105-1)/3)
gen status3 = (q102a-1)/4
recode q1004 (1=1) (2=0) (else=.), gen(employed)
recode q1003 (1=1) (2=2) (3/4 = 3) (5/7 = 4) (else=.), gen(edulevel1)
recode q1003t (1=1) (2=2) (3/4 = 3) (5/7 = 4) (else=.), gen(edulevel2)
recode q1003yem (1=1) (2=2) (3/4 = 3) (5/7 = 4) (else=.), gen(edulevel3)
egen edulevel = rowmean(edulevel1 edulevel2 edulevel3)
gen polint = 1-((q404-1)/3)
recode q103 (1=1) (2=0) (else=.), gen(soctrust)
recode q1012 (1=3) (2=1) (3=6) (4=6) (98/100 = .) (else=.), gen(religion)
gen reli = 1-((q609-1)/2)
recode q1002 (1=0) (2=1), gen(female)
mvdecode q1001, mv(0 9999)
gen age = q1001

drop qid-q2005kw
drop edulevel1 edulevel2 edulevel3
save arab3.dta, replace


//** recoding the Asian Barometer **//
use .\ABS3_merge20130904_release.dta

gen countrymerge = country + 400
gen survey = 4
gen year = year(ir9)
replace year = 2010 if countrymerge == 410 /*this adds the missing dates for Singapore*/

mvdecode q7 q9 q11 q14 q13, mv(7 8 9)
gen trust1a = 1-((q7-1)/3)
gen trust1b = 1-((q9-1)/3)
egen trust1 = rowmean(trust1a trust1b)
gen trust2 = 1-((q11-1)/3)
gen trust3 = 1-((q14-1)/3)
gen trust4 = 1-((q13-1)/3)

mvdecode q129 q42 q1 q43 q4, mv(7 8 9)
mvdecode q91, mv (97 98 99)
gen auth1 = (q129-1)/3
gen dpe2 = (q91-1)/9
gen spe1 = 1-((q42-1)/3)
gen polint = 1-((q43-1)/3)
gen status3 = 1-((q4-1)/4)
recode q23 (1=1) (2=0) (6=0.5) (else=.), gen(soctrust)
recode se9 (1=1) (2=0) (else=.), gen(employed)
recode se5 (1=1) (2=2) (3=2) (4=3) (5=3) (6=3) (7=3) (8=4) (9=4) (10=4) (99=.), gen(edulevel)
mvdecode se7a, mv (90/99)
gen reli = 1-((se7a-1)/3)
recode se6 (1=6) (10=1) (20/26=2) (27/29 = 6) (40/42 = 3) (60=4) (61/65 = 6) (50=5) (30=6) (70/88 = 6) (90=0) (98/100 = .), gen(religion)
recode se2 (1=0) (2=1) (else=.), gen(female)
mvdecode se3a, mv(9)
gen age = se3a

drop country-couweight
save asian3.dta, replace


//** recoding the Latinobarometro **//
use .\Latinobarometro2013.dta
recode idenpa (32=1) (68=2) (76=3) (152=4) (170=5) (188=6) (214=7) (218=8) (222=9) (320=10) (340=11) (484=12) (558=13) (591=14) (600=15) (604=16) (858=17) (862=18) (724=19), gen(country)
gen countrymerge = country + 500
gen survey = 5
gen year = 2013
replace year=2012 if countrymerge==501 /*Argentinian survey was fielded in 2012*/

mvdecode _all, mv(-4 -3 -2 -1)

gen trust1a = 1-((P26TGB_A-1)/3)
gen trust1b = 1-((P26TGB_B-1)/3)
egen trust1 = rowmean(trust1a trust1b)
gen trust2 = 1-((P26TGB_C-1)/3)
gen trust3 = 1-((P28TGB_B-1)/3)
gen trust4 = 1-((P28TGB_A-1)/3)

gen auth1 = (P43TGB_B-1)/3
mvdecode P50TGB_A, mv(-9 -8 -7 -6 -5 -4 -3 -2 -1 5 96)
gen dpe2 = (P50TGB_A-1)/9
gen spe1 = 1-((P66ST-1)/4)
gen status3 = 1-((P6STGBS-1)/4)
gen polint = 1-((P20STGBS-1)/3)
recode P29STGBS(1=1) (2=0) (else=.), gen(soctrust)
gen reli = 1-((S14_A-1)/3)
recode S14 (1=1) (2/6=2) (7/9=6) (10=2) (11=6) (12/14=0) (15=1) (16=3) (17=4) (18/96=6) (97=0) (else=.), gen(religion)
recode S19_A (1=1) (2=1) (3=1)(4=0) (5=0) (6=0) (7=0) (else=.), gen(employed)
recode S17 (1=1) (2=2) (3=2) (4=2) (5=2) (6=2) (7=2) (8=3) (9=3) (10=3) (11=3) (12=3) (13=3) (14=4) (15=4) (16=3) (17=3), gen(edulevel)
recode S10 (1=0) (2=1) (else=.), gen(female)
gen age = S11

drop if country==519 /*drop Spain because different survey questions*/
drop numinves-country
save latino2013.dta, replace


//** recoding the World Values Survey **//
use .\WV6_Data_Stata_v20180912.dta /* this new version of the WVS dataset now contains another country, Haiti (country code: 332). as this was not included when conducting the original analysis, it is dropped here */
drop if V2==332

recode V2 (12=1) (31=2) (32=3) (36=4) (48=5) (51=6) (76=7) (112=8) (152=9) (156=10) (158=11) (170=12) (196=13) (218=14) (233=15) (268=16) (275=17) (276=18) (288=19) (344=20) (356=21) (368=22) (392=23) (398=24) ///
(400=25) (410=26) (414=27) (417=28) (422=29) (434=30) (458=31) (484=32) (504=33) (528=34) (554=35) (566=36) (586=37) (604=38) (608=39) (616=40) (634=41) (642=42) (643=43) (646=44) (702=45) (705=46) (710=47) (716=48) ///
(724=49) (752=50) (764=51) (780=52) (788=53) (792=54) (804=55) (818=56) (840=57) (858=58) (860=59) (887=60), gen(country) /* apparently, the new 2018-09-12 version of the dataset contains country 332 Haiti */
gen countrymerge = country + 600
gen survey = 6
gen year = V262

mvdecode _all, mv(-5/-1)

gen trust1 = 1-((V115-1)/3)
gen trust2 = 1-((V117-1)/3)
gen trust3 = 1-((V113-1)/3)
gen trust4 = 1-((V109-1)/3)

gen auth1 = (V127-1)/3
gen dpe2 = (V141-1)/9
gen spe1 = 1-((V170-1)/3)
gen status3 = (V59-1)/9
gen polint = 1-((V84-1)/3)
recode V24 (1=1) (2=0) (else=.), gen(soctrust)
recode V229 (1/3=1) (4/9=0) (else=.), gen(employed)
recode V248 (1=1) (2/3=2) (4/7=3) (8/9=4) (else=.), gen(edulevel)
recode V144 (0=0) (1=1) (4=6) (5=2) (6=6) (9=2) (12=4) (17=1) (19=2) (2=1) (20=6) (21=6) (22=6) (25=2) (28=6) (29=1) (30=6) (31=5) (34=1) (35=6) (39=6) (42=6) (44=2) (46=2) (48=6) ///
(49=3) (50=6) (52=6) (53=6) (54=6) (55=6) (57=6) (58=6) (59=6) (60=2) (61=2) (62=2) (64=1) (66=6) (68=2) (70=3) (71=6) (73=6) (74=6) (75=3) (77=4) (78=2) (81=6) (85=6) ///
(86=6) (87=6) (89=6) (90=6) (91=6) (12001=6) (360001=6) (528001=2) (528002=2) (710001=2) (710002=6) (else=.), gen(religion)
gen reli = (V152-1)/9
recode V240 (1=0) (2=1) (else=.), gen(female)
gen age = V242

drop V1-country
save wvs6.dta, replace


//** merge the survey data **//
use .\afro5.dta
append using .\americas2012.dta
append using .\arab3.dta
append using .\asian3.dta
append using .\latino2013.dta
append using .\wvs6.dta
save mergedsurveys.dta, replace


//** label and recode the merged survey data **//
use .\mergedsurveys.dta

*** adding an id variable
gen id = _n

*** labeling the data
rename countrymerge country
label define country 101 "Algeria 2013 (Afro)" 102 "Benin 2011 (Afro)" 103 "Botswana 2012 (Afro)" 104 "Burkina Faso 2012 (Afro)" 105 "Burundi 2012 (Afro)" 106 "Cameroon 2013 (Afro)" ///
107 "Cape Verde 2011 (Afro)" 108 "Cote d'Ivoire 2013 (Afro)" 109 "Egypt 2013 (Afro)" 110 "Ethiopia xxxx (Afro, m)" 111 "Ghana 2012 (Afro)" 112 "Guinea 2013 (Afro)" 113 "Kenya 2011 (Afro)" 114 "Lesotho 2012 (Afro)" ///
115 "Liberia 2012 (Afro)" 116 "Madagascar 2013 (Afro)" 117 "Malawi 2012 (Afro)" 118 "Mali 2012 (Afro)" 119 "Mauritius 2012 (Afro)" 120 "Morocco 2013 (Afro)" ///
121 "Mozambique 2012 (Afro)" 122 "Namibia 2012 (Afro)" 123 "Niger 2013 (Afro)" 124 "Nigeria 2013 (Afro)" 125 "Senegal 2013 (Afro)" 126 "Sierra Leone 2012 (Afro)" 127 "South Africa 2011 (Afro)"  ///
128 "Sudan 2013 (Afro)" 129 "Swaziland 2013 (Afro)" 130 "Tanzania 2012 (Afro)" 131 "Togo 2012 (Afro)" 132 "Tunisia 2013 (Afro)" 133 "Uganda 2012 (Afro)" 134 "Zambia 2013 (Afro)" 135 "Zimbabwe 2012 (Afro)" ///
201 "Mexico 2012 (Americas)" 202 "Guatemala 2012 (Americas)" 203 "El Salvador 2012 (Americas)" 204 "Honduras 2012 (Americas)" 205 "Nicaragua 2012 (Americas)" 206 "Costa Rica 2012 (Americas)" 207 "Panama 2012 (Americas)" ///
208 "Colombia 2012 (Americas)" 209 "Ecuador 2012 (Americas)" 210 "Bolivia 2012 (Americas)" 211 "Peru 2012 (Americas)" 212 "Paraguay 2012 (Americas)" 213 "Chile 2012 (Americas)" 214 "Uruguay 2012 (Americas)" ///
215 "Brazil 2012 (Americas)" 216 "Venezuela 2012 (Americas)" 217 "Argentina 2012 (Americas)" 221 "Dominican Republic 2012 (Americas)" 222 "Haiti 2012 (Americas)" 223 "Jamaica 2012 (Americas)" 224 "Guyana 2012 (Americas)" ///
225 "Trinidad and Tobago 2012 (Americas)" 226 "Belize 2012 (Americas)" 227 "Suriname 2012 (Americas)" 240 "USA 2012 (Americas)" 241 "Canada 2012 (Americas)" ///
301 "Algeria 2013 (Arab)" 305 "Egypt 2013 (Arab)" 307 "Iraq 2013 (Arab)" 308 "Jordan ???? (Arab)" 309 "Kuwait 2014 (Arab)" 310 "Lebanon 2013 (Arab)" 311 "Libya 2014 (Arab)" ///
313 "Morocco 2013-14 (Arab)" 315 "Palestine 2012 (Arab)" 319 "Sudan 2013 (Arab)" 321 "Tunisia 2013 (Arab)" 322 "Yemen 2013 (Arab)" ///
401 "Japan 2011 (Asian)" 402 "Hong Kong 2012 (Asian)"  403 "South Korea 2011 (Asian)" 404 "China 2011 (Asian)" 405 "Mongolia 2010 (Asian)" 406 "Philippines 2010 (Asian)" ///
407 "Taiwan 2010 (Asian)" 408 "Thailand 2010 (Asian)" 409 "Indonesia 2011 (Asian)" 410 "Singapore 2010 (Asian)" 411 "Vietnam 2010 (Asian)" 412 "Cambodia 2012 (Asian)" 413 "Malaysia 2011 (Asian)" ///
501 "Argentina 2012 (Latino)" 502 "Bolivia 2013 (Latino)" 503 "Brazil 2013 (Latino)" 504 "Chile 2013 (Latino)" 505 "Colombia 2013 (Latino)" 506 "Costa Rica 2013 (Latino)" 507 "Dominican Republic 2013 (Latino)" ///
508 "Ecuador 2013 (Latino)" 509 "El Salvador 2013 (Latino)" 510 "Guatemala 2013 (Latino)" 511 "Honduras 2013 (Latino)" 512 "Mexico 2013 (Latino)" 513 "Nicaragua 2013 (Latino)" 514 "Panama 2013 (Latino)" ///
515 "Paraguay 2013 (Latino)" 516 "Peru 2013 (Latino)" 517 "Uruguay 2013 (Latino)" 518 "Venezuela 2013 (Latino)" 519 "Spain 2013 (Latino)" ///
601 "Algeria 2013 (WVS)" 602 "Azerbaijan 2011 (WVS)" 603 "Argentina 2013 (WVS)" 604 "Australia 2012 (WVS)" 605 "Bahrain 2014 (WVS)" 606 "Armenia 2011 (WVS)" 607 "Brazil 2014 (WVS)" 608 "Belarus 2011 (WVS)" ///
609 "Chile 2011 (WVS)" 610 "China 2012 (WVS)" 611 "Taiwan 2012 (WVS)" 612 "Colombia 2012 (WVS)" 613 "Cyprus 2011 (WVS)" 614 "Ecuador 2013 (WVS)" 615 "Estonia 2011 (WVS)" 616 "Georgia 2014 (WVS)" ///
617 "Palestine 2013 (WVS)" 618 "Germany 2013 (WVS)" 619 "Ghana 2012 (WVS)" 620 "Hong Kong 2013 (WVS)" 621 "India 2014 (WVS)" 622 "Iraq 2012 (WVS)" 623 "Japan 2010 (WVS)" 624 "Kazakhastan 2011 (WVS)" 625 "Jordan 2014 (WVS)" ///
626 "South Korea 2010 (WVS)" 627 "Kuwait 2014 (WVS)" 628 "Kyrgyzstan 2011 (WVS)" 629 "Lebanon 2013 (WVS)" 630 "Libya 2014 (WVS)" 631 "Malaysia 2012 (WVS)" 632 "Mexico 2012 (WVS)" 633 "Morocco 2011 (WVS)" ///
634 "Netherlands 2012 (WVS)" 635 "New Zealand 2011 (WVS)" 636 "Nigeria 2011 (WVS)" 637 "Pakistan 2012 (WVS)" 638 "Peru 2012 (WVS)" 639 "Philippines 2012 (WVS)" 640 "Poland 2012 (WVS)" ///
641 "Qatar 2010 (WVS)" 642 "Romania 2012 (WVS)" 643 "Russia 2011 (WVS)" 644 "Rwanda 2012 (WVS)" 645 "Singapore 2012 (WVS)" 646 "Slovenia 2011 (WVS)" 647 "South Africa 2013 (WVS)" 648 "Zimbabwe 2012 (WVS)" ///
649 "Spain 2011 (WVS)" 650 "Sweden 2011 (WVS)" 651 "Thailand 2013 (WVS)" 652 "Trinidad and Tobago 2011 (WVS)" 653 "Tunisia 2013 (WVS)" 654 "Turkey 2011 (WVS)" 655 "Ukraine 2011 (WVS)" ///
656 "Egypt 2013 (WVS)" 657 "USA 2011 (WVS)" 658 "Uruguay 2011 (WVS)" 659 "Uzbekistan 2011 (WVS)" 660 "Yemen 2014 (WVS)"
label values country country

*** correct for coding mistakes and alternative date formats used in some cases
replace year = 2011 if country==404 | year==1583 | year==2000 | year==2077 /*China 2011*/
replace year = 2014 if country==313 /*Morocco 2013-2014*/
replace year = 2014 if country==621 /*India 2014*/

label define survey 1 "Afrobarometer" 2 "AmericasBarometer" 3 "Arab Barometer" 4 "Asian Barometer" 5 "Latinobarometro" 6 "World Values Survey"
label val survey survey

lab var trust1a "trust in president"
lab var trust1b "trust in government"
lab var trust1 "trust in president/government"
lab var trust2 "trust in parliament"
lab var trust3 "trust in police"
lab var trust4 "trust in military"
lab define trust 0 "none at all" 1 "a great deal of trust"
lab val trust1a trust1b trust1 trust2 trust3 trust4 trust

lab var auth1 "We should get rid of parliament and elections and have a strong leader decide things"
lab define approval 0 "strongly approve" 1 "strongly disapprove"
lab val auth1 approval

lab var dpe2 "Level of democracy in [country] today"
lab define dpe2 0 "not a democracy" 1 "a full democracy"
lab val dpe2 dpe2

lab var spe1 "How safe is neighbourhood?"
lab define spe1 0 "very unsafe" 1 "completely safe"
lab val spe1 spe1

lab var status3 "family living conditions/economic situation"
lab define goodbad 0 "very bad" 1 "very good"
lab val status3 goodbad

lab var polint "interest in politics"
lab define polint 0 "not at all interested" 1 "very interested"
lab val polint polint

lab var soctrust "Most people can be trusted"
lab var employed "Are you currently employed?"
lab var female "female"
lab define yn 0 "no" 1 "yes"
lab val employed soctrust female yn

lab var edulevel "Level of formal education"
lab define edulevel 1 "none" 2 "(some) primary" 3 "(some) secondary" 4 "(some) tertiary"
lab val edulevel edulevel

lab var reli "Importance of religion"
lab define reli 0 "not at all important" 1 "very important"
lab val reli reli

lab var religion "Religion"
lab define religion 0 "none" 1 "Catholic (Christian)" 2 "Protestant" 3 "Muslim" 4 "Buddhist" 5 "Hindu" 6 "other"
lab val religion religion

*** collapsing dupletes
gen country_orig = country /*preserve original country codes*/
replace country=101 if country==301 | country==601 /*Algeria 2013*/
replace country=109 if country==305 | country==656 /*Egypt 2013*/
replace country=111 if country==619 /*Ghana 2012*/
replace country=311 if country==630 /*Libya 2014*/
replace country=128 if country==319 /*Sudan 2013*/
replace country=132 if country==321 | country==653 /*Tunisia 2013*/
replace country=135 if country==648 /*Zimbabwe 2012*/
replace country=217 if country==501 /*Argentina 2012*/
replace country=208 if country==612 /*Colombia 2012*/
replace country=508 if country==614 /*Ecuador 2013*/
replace country=201 if country==632 /*Mexico 2012*/
replace country=211 if country==638 /*Peru 2012*/
replace country=309 if country==627 /*Kuwait 2014*/
replace country=310 if country==629 /*Lebanon 2013*/

save mergedsurveys.dta, replace

*************************
 adding the macro data
*************************

//** recoding the V-Dem data **//
use .\V-Dem-CY-IC-v8.dta

drop if year <=2009
keep country_name country_id year v2x_libdem v2x_regime
save vdem_v8.dta, replace

gen country = .
replace country=101 if country_name=="Algeria" & year==2013
replace country=102 if country_name=="Benin" & year==2011
replace country=103 if country_name=="Botswana" & year==2012
replace country=104 if country_name=="Burkina Faso" & year==2012
replace country=105 if country_name=="Burundi" & year==2012
replace country=106 if country_name=="Cameroon" & year==2013
replace country=107 if country_name=="Cape Verde" & year==2011
replace country=108 if country_name=="Ivory Coast" & year==2013
replace country=109 if country_name=="Egypt" & year==2013
replace country=111 if country_name=="Ghana" & year==2012
replace country=112 if country_name=="Guinea" & year==2013
replace country=113 if country_name=="Kenya" & year==2011
replace country=114 if country_name=="Lesotho" & year==2012
replace country=115 if country_name=="Liberia" & year==2012
replace country=116 if country_name=="Madagascar" & year==2013
replace country=117 if country_name=="Malawi" & year==2012
replace country=118 if country_name=="Mali" & year==2012
replace country=119 if country_name=="Mauritius" & year==2012
replace country=120 if country_name=="Morocco" & year==2013
replace country=121 if country_name=="Mozambique" & year==2012
replace country=122 if country_name=="Namibia" & year==2012
replace country=123 if country_name=="Niger" & year==2013
replace country=124 if country_name=="Nigeria" & year==2013
replace country=125 if country_name=="Senegal" & year==2013
replace country=126 if country_name=="Sierra Leone" & year==2012
replace country=127 if country_name=="South Africa" & year==2011
replace country=128 if country_name=="Sudan" & year==2013
replace country=129 if country_name=="Swaziland" & year==2013
replace country=130 if country_name=="Tanzania" & year==2012
replace country=131 if country_name=="Togo" & year==2012
replace country=132 if country_name=="Tunisia" & year==2013
replace country=133 if country_name=="Uganda" & year==2012
replace country=134 if country_name=="Zambia" & year==2013
replace country=135 if country_name=="Zimbabwe" & year==2012
replace country=201 if country_name=="Mexico" & year==2012
replace country=202 if country_name=="Guatemala" & year==2012
replace country=203 if country_name=="El Salvador" & year==2012
replace country=204 if country_name=="Honduras" & year==2012
replace country=205 if country_name=="Nicaragua" & year==2012
replace country=206 if country_name=="Costa Rica" & year==2012
replace country=207 if country_name=="Panama" & year==2012
replace country=208 if country_name=="Colombia" & year==2012
replace country=209 if country_name=="Ecuador" & year==2012
replace country=210 if country_name=="Bolivia" & year==2012
replace country=211 if country_name=="Peru" & year==2012
replace country=212 if country_name=="Paraguay" & year==2012
replace country=213 if country_name=="Chile" & year==2012
replace country=214 if country_name=="Uruguay" & year==2012
replace country=215 if country_name=="Brazil" & year==2012
replace country=216 if country_name=="Venezuela" & year==2012
replace country=217 if country_name=="Argentina" & year==2012
replace country=221 if country_name=="Dominican Republic" & year==2012
replace country=222 if country_name=="Haiti" & year==2012
replace country=223 if country_name=="Jamaica" & year==2012
replace country=224 if country_name=="Guyana" & year==2012
replace country=225 if country_name=="Trinidad and Tobago" & year==2012
replace country=226 if country_name=="Belize" & year==2012 // no data for Belize
replace country=227 if country_name=="Suriname" & year==2012
replace country=240 if country_name=="United States of America" & year==2012
replace country=241 if country_name=="Canada" & year==2012
/*replace country=301 if country_name=="Algeria" & year==2013*/
/*replace country=305 if country_name=="Egypt" & year==2013*/
replace country=307 if country_name=="Iraq" & year==2013
replace country=308 if country_name=="Jordan" & year==2012
replace country=309 if country_name=="Kuwait" & year==2014
replace country=310 if country_name=="Lebanon" & year==2013
replace country=311 if country_name=="Libya" & year==2014
replace country=313 if country_name=="Morocco" & year==2014
replace country=315 if country_name=="Palestine/West Bank" & year==2012
/*replace country=319 if country_name=="Sudan" & year==2013*/
/*replace country=321 if country_name=="Tunisia" & year==2013*/
replace country=322 if country_name=="Yemen" & year==2013
replace country=401 if country_name=="Japan" & year==2011
replace country=402 if country_name=="Hong Kong" & year==2012
replace country=403 if country_name=="South Korea" & year==2011
replace country=404 if country_name=="China" & year==2011
replace country=405 if country_name=="Mongolia" & year==2010
replace country=406 if country_name=="Philippines" & year==2010
replace country=407 if country_name=="Taiwan" & year==2010
replace country=408 if country_name=="Thailand" & year==2010
replace country=409 if country_name=="Indonesia" & year==2011
replace country=410 if country_name=="Singapore" & year==2010
replace country=411 if country_name=="Democratic Republic of Vietnam" & year==2010
replace country=412 if country_name=="Cambodia" & year==2012
replace country=413 if country_name=="Malaysia" & year==2011
/*replace country=501 if country_name=="Argentina" & year==2012*/
replace country=502 if country_name=="Bolivia" & year==2013
replace country=503 if country_name=="Brazil" & year==2013
replace country=504 if country_name=="Chile" & year==2013
replace country=505 if country_name=="Colombia" & year==2013
replace country=506 if country_name=="Costa Rica" & year==2013
replace country=507 if country_name=="Dominican Republic" & year==2013
replace country=508 if country_name=="Ecuador" & year==2013
replace country=509 if country_name=="El Salvador" & year==2013
replace country=510 if country_name=="Guatemala" & year==2013
replace country=511 if country_name=="Honduras" & year==2013
replace country=512 if country_name=="Mexico" & year==2013
replace country=513 if country_name=="Nicaragua" & year==2013
replace country=514 if country_name=="Panama" & year==2013
replace country=515 if country_name=="Paraguay" & year==2013
replace country=516 if country_name=="Peru" & year==2013
replace country=517 if country_name=="Uruguay" & year==2013
replace country=518 if country_name=="Venezuela" & year==2013
/*replace country=601 if country_name=="Algeria" & year==2013*/
replace country=602 if country_name=="Azerbaijan" & year==2011
replace country=603 if country_name=="Argentina" & year==2013
replace country=604 if country_name=="Australia" & year==2012
replace country=605 if country_name=="Bahrain" & year==2014
replace country=606 if country_name=="Armenia" & year==2011
replace country=607 if country_name=="Brazil" & year==2014
replace country=608 if country_name=="Belarus" & year==2011
replace country=609 if country_name=="Chile" & year==2011
replace country=610 if country_name=="China" & year==2012
replace country=611 if country_name=="Taiwan" & year==2012
/*replace country=612 if country_name=="Colombia" & year==2012*/
replace country=613 if country_name=="Cyprus" & year==2011
/*replace country=614 if country_name=="Ecuador" & year==2013*/
replace country=615 if country_name=="Estonia" & year==2011
replace country=616 if country_name=="Georgia" & year==2014
replace country=617 if country_name=="Palestine/West Bank" & year==2013
replace country=618 if country_name=="Germany" & year==2013
/*replace country=619 if country_name=="Ghana" & year==2012*/
replace country=620 if country_name=="Hong Kong" & year==2013
replace country=621 if country_name=="India" & year==2014
replace country=622 if country_name=="Iraq" & year==2012
replace country=623 if country_name=="Japan" & year==2010
replace country=624 if country_name=="Kazakhstan" & year==2011
replace country=625 if country_name=="Jordan" & year==2014
replace country=626 if country_name=="South Korea" & year==2010
/*replace country=627 if country_name=="Kuwait" & year==2014*/
replace country=628 if country_name=="Kyrgyzstan" & year==2011
/*replace country=629 if country_name=="Lebanon" & year==2013*/
/*replace country=630 if country_name=="Libya" & year==2014*/
replace country=631 if country_name=="Malaysia" & year==2012
/*replace country=632 if country_name=="Mexico" & year==2012*/
replace country=633 if country_name=="Morocco" & year==2011
replace country=634 if country_name=="Netherlands" & year==2012
replace country=635 if country_name=="New Zealand" & year==2011
replace country=636 if country_name=="Nigeria" & year==2011
replace country=637 if country_name=="Pakistan" & year==2012
/*replace country=638 if country_name=="Peru" & year==2012*/
replace country=639 if country_name=="Philippines" & year==2012
replace country=640 if country_name=="Poland" & year==2012
replace country=641 if country_name=="Qatar" & year==2010
replace country=642 if country_name=="Romania" & year==2012
replace country=643 if country_name=="Russia" & year==2011
replace country=644 if country_name=="Rwanda" & year==2012
replace country=645 if country_name=="Singapore" & year==2012
replace country=646 if country_name=="Slovenia" & year==2011
replace country=647 if country_name=="South Africa" & year==2013
/*replace country=648 if country_name=="Zimbabwe" & year==2012*/
replace country=649 if country_name=="Spain" & year==2011
replace country=650 if country_name=="Sweden" & year==2011
replace country=651 if country_name=="Thailand" & year==2013
replace country=652 if country_name=="Trinidad and Tobago" & year==2011
/*replace country=653 if country_name=="Tunisia" & year==2013*/
replace country=654 if country_name=="Turkey" & year==2011
replace country=655 if country_name=="Ukraine" & year== 2011
/*replace country=656 if country_name=="Egypt" & year==2013*/
replace country=657 if country_name=="United States of America" & year==2011
replace country=658 if country_name=="Uruguay" & year==2011
replace country=659 if country_name=="Uzbekistan" & year==2011
replace country=660 if country_name=="Yemen" & year==2014

sort country
rename year vdemyear
rename country_id vdemid
drop if country==.
tab country
label define country 101 "Algeria 2013 (Afro)" 102 "Benin 2011 (Afro)" 103 "Botswana 2012 (Afro)" 104 "Burkina Faso 2012 (Afro)" 105 "Burundi 2012 (Afro)" 106 "Cameroon 2013 (Afro)" ///
107 "Cape Verde 2011 (Afro)" 108 "Cote d'Ivoire 2013 (Afro)" 109 "Egypt 2013 (Afro)" 110 "Ethiopia xxxx (Afro, m)" 111 "Ghana 2012 (Afro)" 112 "Guinea 2013 (Afro)" 113 "Kenya 2011 (Afro)" 114 "Lesotho 2012 (Afro)" ///
115 "Liberia 2012 (Afro)" 116 "Madagascar 2013 (Afro)" 117 "Malawi 2012 (Afro)" 118 "Mali 2012 (Afro)" 119 "Mauritius 2012 (Afro)" 120 "Morocco 2013 (Afro)" ///
121 "Mozambique 2012 (Afro)" 122 "Namibia 2012 (Afro)" 123 "Niger 2013 (Afro)" 124 "Nigeria 2013 (Afro)" 125 "Senegal 2013 (Afro)" 126 "Sierra Leone 2012 (Afro)" 127 "South Africa 2011 (Afro)"  ///
128 "Sudan 2013 (Afro)" 129 "Swaziland 2013 (Afro)" 130 "Tanzania 2012 (Afro)" 131 "Togo 2012 (Afro)" 132 "Tunisia 2013 (Afro)" 133 "Uganda 2012 (Afro)" 134 "Zambia 2013 (Afro)" 135 "Zimbabwe 2012 (Afro)" ///
201 "Mexico 2012 (Americas)" 202 "Guatemala 2012 (Americas)" 203 "El Salvador 2012 (Americas)" 204 "Honduras 2012 (Americas)" 205 "Nicaragua 2012 (Americas)" 206 "Costa Rica 2012 (Americas)" 207 "Panama 2012 (Americas)" ///
208 "Colombia 2012 (Americas)" 209 "Ecuador 2012 (Americas)" 210 "Bolivia 2012 (Americas)" 211 "Peru 2012 (Americas)" 212 "Paraguay 2012 (Americas)" 213 "Chile 2012 (Americas)" 214 "Uruguay 2012 (Americas)" ///
215 "Brazil 2012 (Americas)" 216 "Venezuela 2012 (Americas)" 217 "Argentina 2012 (Americas)" 221 "Dominican Republic 2012 (Americas)" 222 "Haiti 2012 (Americas)" 223 "Jamaica 2012 (Americas)" 224 "Guyana 2012 (Americas)" ///
225 "Trinidad and Tobago 2012 (Americas)" 226 "Belize 2012 (Americas)" 227 "Suriname 2012 (Americas)" 240 "USA 2012 (Americas)" 241 "Canada 2012 (Americas)" ///
301 "Algeria 2013 (Arab)" 305 "Egypt 2013 (Arab)" 307 "Iraq 2013 (Arab)" 308 "Jordan ???? (Arab)" 309 "Kuwait 2014 (Arab)" 310 "Lebanon 2013 (Arab)" 311 "Libya 2014 (Arab)" ///
313 "Morocco 2013-14 (Arab)" 315 "Palestine 2012 (Arab)" 319 "Sudan 2013 (Arab)" 321 "Tunisia 2013 (Arab)" 322 "Yemen 2013 (Arab)" ///
401 "Japan 2011 (Asian)" 402 "Hong Kong 2012 (Asian)"  403 "South Korea 2011 (Asian)" 404 "China 2011 (Asian)" 405 "Mongolia 2010 (Asian)" 406 "Philippines 2010 (Asian)" ///
407 "Taiwan 2010 (Asian)" 408 "Thailand 2010 (Asian)" 409 "Indonesia 2011 (Asian)" 410 "Singapore 2010 (Asian)" 411 "Vietnam 2010 (Asian)" 412 "Cambodia 2012 (Asian)" 413 "Malaysia 2011 (Asian)" ///
501 "Argentina 2012 (Latino)" 502 "Bolivia 2013 (Latino)" 503 "Brazil 2013 (Latino)" 504 "Chile 2013 (Latino)" 505 "Colombia 2013 (Latino)" 506 "Costa Rica 2013 (Latino)" 507 "Dominican Republic 2013 (Latino)" ///
508 "Ecuador 2013 (Latino)" 509 "El Salvador 2013 (Latino)" 510 "Guatemala 2013 (Latino)" 511 "Honduras 2013 (Latino)" 512 "Mexico 2013 (Latino)" 513 "Nicaragua 2013 (Latino)" 514 "Panama 2013 (Latino)" ///
515 "Paraguay 2013 (Latino)" 516 "Peru 2013 (Latino)" 517 "Uruguay 2013 (Latino)" 518 "Venezuela 2013 (Latino)" 519 "Spain 2013 (Latino)" ///
601 "Algeria 2013 (WVS)" 602 "Azerbaijan 2011 (WVS)" 603 "Argentina 2013 (WVS)" 604 "Australia 2012 (WVS)" 605 "Bahrain 2014 (WVS)" 606 "Armenia 2011 (WVS)" 607 "Brazil 2014 (WVS)" 608 "Belarus 2011 (WVS)" ///
609 "Chile 2011 (WVS)" 610 "China 2012 (WVS)" 611 "Taiwan 2012 (WVS)" 612 "Colombia 2012 (WVS)" 613 "Cyprus 2011 (WVS)" 614 "Ecuador 2013 (WVS)" 615 "Estonia 2011 (WVS)" 616 "Georgia 2014 (WVS)" ///
617 "Palestine 2013 (WVS)" 618 "Germany 2013 (WVS)" 619 "Ghana 2012 (WVS)" 620 "Hong Kong 2013 (WVS)" 621 "India 2014 (WVS)" 622 "Iraq 2012 (WVS)" 623 "Japan 2010 (WVS)" 624 "Kazakhastan 2011 (WVS)" 625 "Jordan 2014 (WVS)" ///
626 "South Korea 2010 (WVS)" 627 "Kuwait 2014 (WVS)" 628 "Kyrgyzstan 2011 (WVS)" 629 "Lebanon 2013 (WVS)" 630 "Libya 2014 (WVS)" 631 "Malaysia 2012 (WVS)" 632 "Mexico 2012 (WVS)" 633 "Morocco 2011 (WVS)" ///
634 "Netherlands 2012 (WVS)" 635 "New Zealand 2011 (WVS)" 636 "Nigeria 2011 (WVS)" 637 "Pakistan 2012 (WVS)" 638 "Peru 2012 (WVS)" 639 "Philippines 2012 (WVS)" 640 "Poland 2012 (WVS)" ///
641 "Qatar 2010 (WVS)" 642 "Romania 2012 (WVS)" 643 "Russia 2011 (WVS)" 644 "Rwanda 2012 (WVS)" 645 "Singapore 2012 (WVS)" 646 "Slovenia 2011 (WVS)" 647 "South Africa 2013 (WVS)" 648 "Zimbabwe 2012 (WVS)" ///
649 "Spain 2011 (WVS)" 650 "Sweden 2011 (WVS)" 651 "Thailand 2013 (WVS)" 652 "Trinidad and Tobago 2011 (WVS)" 653 "Tunisia 2013 (WVS)" 654 "Turkey 2011 (WVS)" 655 "Ukraine 2011 (WVS)" ///
656 "Egypt 2013 (WVS)" 657 "USA 2011 (WVS)" 658 "Uruguay 2011 (WVS)" 659 "Uzbekistan 2011 (WVS)" 660 "Yemen 2014 (WVS)"
label values country country

gen row = .
replace row=1 if (v2x_regime==2 | v2x_regime==3)
replace row=0 if (v2x_regime==0 | v2x_regime==1)
tab row
save vdem_v8.dta, replace /*this dataset does not contain data for Belize*/


//** merging the V-Dem data with the survey data **//
use .\mergedsurveys.dta
merge m:1 country using vdem_v8.dta
save mergesurveysvdem.dta, replace


//** adding additional macro data **//
use .\mergesurveysvdem.dta

*** add and recode FH data
recode country (101=5.5) (102=2) (103=2.5) (104=4) (105=5) (106=6) (107=1) (108=4.5) (109=5.5) (110=6) (111=1.5) (112=5) (113=3.5) (114=2.5) (115=3.5) (116=4.5) (117=3.5) (118=6) (119=1.5) (120=4.5) (121=3.5) ///
(122=2) (123=3.5) (124=4) (125=2) (126=2.5) (127=2) (128=7) (129=6) (130=3) (131=4.5) (132=3) (133=4.5) (134=3.5) (135=6) ///
(201=3.0) (202=3.5) (203=2.5) (204=4.0) (205=4.5) (206=1.0) (207=1.5) (208=3.5) (209=3.0) (210=3.0) (211=2.5) (212=3.0) (213=1.0) (214=1.0) (215=2.0) (216=5.0) (217=2.0) (221=2.0) (222=4.5) (223=2.5) (224=2.5) ///
(225=2.0) (226=1.5) (227=2.0) (240=1.0) (241=1.0) ///
(301=5.5) (305=5.5) (307=5.5) (308=5.5) (309=5) (310=4.5) (311=6) (313=4.5) (315=5.5) (319=7) (321=3) (322=6) ///
(401=1.5) (402=3.5) (403=1.5) (404=6.5) (405=2) (406=3) (407=1.5) (408=4.5) (409=2.5) (410=4.5) (411=6) (412=5.5) (413=4) ///
(501=2) (502=3) (503=2) (504=1) (505=3.5) (506=1) (507=2) (508=3) (509=2.5) (510=3.5) (511=4) (512=3) (513=4.5) (514=1.5) (515=3) (516=2.5) (517=1) (518=5) (519=1) ///
(601=5.5) (602=5.5) (603=2.0) (604=1.0) (605=6.5) (606=5.0) (607=2.0) (608=6.5) (609=1.0) (610=6.5) (612=3.5) (613=1.0) (614=3.0) (615=1.0) (656=5.5) (616=3.0) (618=1.0) (619=1.5) (620=3.5) (621=2.5) (622=6.0) ///
(623=1.5) (625=5.5) (624=5.5) (627=5.0) (628=5.0) (629=4.5) (630=6.0) (631=4.0) (632=3.0) (633=4.5) (634=1.0) (635=1.0) (636=4.0) (637=4.5) (617= 5.5) (638=2.5) (639=3.0) (640=1.0) (641=5.5) (642=2.0) (643=5.5) ///
(644=6.0) (645=4.0) (646=1.0) (647=2.0) (626=1.5) (649=1.0) (650=1.0) (611=1.5) (651=4.0) (652=2.0) (653=3.0) (654=3.0) (655=3.5) (658=1.0) (657=1.0) (659=7.0) (660=6.0) (648=6.0), gen(fhscore)
gen fh01 = (7-fhscore)/6
lab var fh01 "Freedom House score 0-1"
lab define fh01 0 "unfree" 1 "free"
lab val fh01 fh01

*** add information on democracy/autocracy from FH List of Electoral Democracies
gen demaut=.
replace demaut=1 if country==501 | country==217 | country==603 | country==604 | country==226 | country==102 | country==502 | country==210 | country==103 | country==607 | country==215 | country==503 | country==241 | country==609 ///
| country==107 | country==504 | country==213 | country==208 | country==505 | country==612 | country==506 | country==206 | country==613 | country==507 | country==221 | country==209 | country==508 | country==614 | country==509 ///
| country==203 | country==615 | country==616 | country==618 | country==111 | country==619 | country==202 | country==510 | country==224 | country==621 | country==409 | country==223 | country==401 | country==623 | country==114 ///
| country==115 | country==117 | country==119 | country==201 | country==512 | country==632 | country==405 | country==122 | country==634 | country==635 | country==123 | country==207 | country==514 | country==212 | country==515 ///
| country==516 | country==211 | country==638 | country==406 | country==639 | country==640 | country==642 | country==125 | country==126 | country==646 | country==647 | country==127 | country==403 | country==626 | country==649 ///
| country==227 | country==650 | country==407 | country==611 | country==130 | country==651 | country==652 | country==408 | country==132 | country==321 | country==653 | country==654 | country==655 | country==658 | country==214 ///
| country==517 | country==240 | country==657 | country==134 | country==225
replace demaut=0 if country==101 | country==301 | country==601 | country==606 | country==602 | country==605 | country==608 | country==104 | country==105 | country==412 | country==106 | country==610 | country==404 | country==108 ///
| country==112 | country==222 | country==204 | country==511 | country==402 | country==620 | country==622 | country==307 | country==624 | country==113 | country==309 | country==627 | country==628 | country==629 | country==310 ///
| country==116 | country==413 | country==631 | country==120 | country==313 | country==633 | country==121 | country==205 | country==513 | country==124 | country==636 | country==637 | country==641 | country==643 | country==644 ///
| country==410 | country==645 | country==128 | country==131 | country==133 | country==659 | country==216 | country==518 | country==411 | country==322 | country==660 | country==319 | country==135 | country==648 ///
| country==408 | country==109 | country==118 | country==129 | country==308 | country==311 | country==315 | country==617 | country==625

*** code transitional/civil war/lack of state monopoly countries
replace demaut=9 if country==109 | country==118 | country==305 | country==311 | country==315 | country==617 | country==630 | country==656 | country==660
*** code linchpin monarchies
replace demaut=8 if country==129 | country==308 | country==625

lab define demaut 0 "autocracy" 1 "democracy" 8 "linchpin monarchy" 9 "transitional"
lab val demaut demaut
tab country if demaut==1
tab country if demaut==0
tab country if demaut==9 | demaut==8
sum v2x_libdem
tab country if v2x_libdem==.
*** compute measure of democratic quality
egen demperf = rowmean(fh01 v2x_libdem)


//** dropping transitional regimes etc. **//
drop if demaut==9 | demaut==8
drop if country==519 /*Spain from Latinobarometro*/

numlabel _all, add


//** construct and import factor scores from Mplus **//
stata2mplus country demaut survey id trust1 trust2 trust3 trust4 ///
using prq, missing(999) replace

/* execute Mplus code: prq.inp, then trust.inp */

clear all
import delimited v1 trust1 trust2 trust3 trust4 id trust_ trust_SE demaut using trust.dat, delimiter(space, collapse) varnames(nonames) 
destring trust1 trust2 trust3 trust4 id, force replace
drop v1
save trust.dta, replace
use .\prq.dta
merge 1:1 id using trust.dta, keepusing(trust_ trust_SE) nogenerate

sum trust_
gen trust = ((trust_-r(min))/(r(max)-r(min)))
sum trust
label variable trust "political trust"

save prq.dta, replace


*************************
 analysis
*************************
use .\prq.dta

//** analyses for tables in the main paper **//
**main analysis: democratic value orientations, perceptions of democratic quality, and political trust (models 1 and 2)
*combined data - model 1: no interaction effect
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust), nested save(prq_table1.doc) replace dec(2)
estat ic
*combined data - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust), nested save(prq_table1.doc) reset dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figure1.gph)
estat ic

*democracies only - model 1: no interaction effect
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if demaut==1, nested save(prq_table2.doc) dec(2) 
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if demaut==1, nested save(prq_table2.doc) reset dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figure2a.gph)
estat ic

*autocracies only - model 1: no interaction effect
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if demaut==0, nested save(prq_table2.doc) append dec(2) 
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if demaut==0, nested save(prq_table2.doc) dec(2) 
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figure2b.gph)
estat ic

**relationship between level of democracy and perceptions of democratic quality**
corr dpe2 demperf
corr dpe2 demperf if demaut==1
corr dpe2 demperf if demaut==0

bysort country: sum dpe2
by country, sort: egen dpe_lvl2 = mean(dpe2)
by country: sum dpe2 dpe_lvl2
corr dpe_lvl2 demperf
corr dpe_lvl2 demperf if demaut==1
corr dpe_lvl2 demperf if demaut==0


//** analyses for print appendix **//
**robustness check 1: interaction with demperf (model 3)
*combined data
asdoc mixed trust c.auth1##c.demperf dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust), nested save(prq_tableA2.doc) reset dec(2)
margins, dydx(auth1) at (demperf=(0 (0.1) 1)) vsquish
marginsplot, x(demperf)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureA1.gph)
estat ic

*democracies only
asdoc mixed trust c.auth1##c.demperf dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==1, nested save(prq_tableA2.doc) append dec(2)
margins, dydx(auth1) at (demperf=(0 (0.1) 1)) vsquish
marginsplot, x(demperf)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureA2a.gph)
estat ic

*autocracies only
asdoc mixed trust c.auth1##c.demperf dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==0, nested save(prq_tableA2.doc) append dec(2)
margins, dydx(auth1) at (demperf=(0 (0.1) 1)) vsquish
marginsplot, x(demperf)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureA2b.gph)
estat ic


//** analyses for online supplemental information **//
/* factor analyses: execute Mplus code: trust_CFA.inp, trust_MGCFA1.inp, trust_MGCFA1.inp, trust_MGCFA1.inp, trust_MGCFA1.inp */

**robustness check 2: interaction with demaut (model 2c)
asdoc mixed trust c.auth1##c.demaut dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust), nested save(prq_tableB7.doc) reset dec(2)
estat ic

**robustness check 3: interaction with demperf, without dpe (model 4)
*combined data
asdoc mixed trust c.auth1##c.demperf soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust), nested save(prq_tableB8.doc) reset dec(2)
estat ic

*democracies only
asdoc mixed trust c.auth1##c.demperf soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==1, nested save(prq_tableB8.doc) dec(2)
estat ic

*autocracies only
asdoc mixed trust c.auth1##c.demperf soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==0, nested save(prq_tableB8.doc) dec(2)
estat ic


**robustness check 4: using individual surveys instead of combined dataset (models 1 and 2)
*democracies and autocracies combined - model 1: no interaction effect, Afrobarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1, nested save(prq_tableB6.doc) reset dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe 
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1a.gph)
estat ic

*democracies and autocracies combined - model 1: no interaction effect, AmericasBarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2, nested save(prq_tableB6.doc) dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1b.gph)
estat ic

*democracies and autocracies combined - model 1: no interaction effect, Arab Barometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==3, nested save(prq_tableB6.doc) dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==3, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1c.gph)
estat ic

*democracies and autocracies combined - model 1: no interaction effect, Asian Barometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4, nested save(prq_tableB6.doc) dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1d.gph)
estat ic

*democracies and autocracies combined - model 1: no interaction effect, Latinobarometro
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5, nested save(prq_tableB6.doc) dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1e.gph)
estat ic

*democracies and autocracies combined - model 1: no interaction effect, World Values Survey
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6, nested save(prq_tableB6.doc) dec(2)
estat ic
*democracies and autocracies combined - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6, nested save(prq_tableB6.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB1f.gph)
estat ic


*democracies only - model 1: no interaction effect, Afrobarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1 & demaut==1, nested save(prq_tableB9.doc) reset dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2a.gph)
estat ic

*democracies only - model 1: no interaction effect, AmericasBarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2 & demaut==1, nested save(prq_tableB9.doc) dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2b.gph)
estat ic

*democracies only - model 1: no interaction effect, Arab Barometer - using regular OLS regression b/c it's only 1 level-2 case
asdoc regress trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age if survey==3 & demaut==1, nested save(prq_tableB9.doc) dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc regress trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age if survey==3 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2c.gph)
estat ic

*democracies only - model 1: no interaction effect, Asian Barometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4 & demaut==1, nested save(prq_tableB9.doc) dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2d.gph)
estat ic

*democracies only - model 1: no interaction effect, Latinobarometro
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5 & demaut==1, nested save(prq_tableB9.doc) dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2e.gph)
estat ic

*democracies only - model 1: no interaction effect, World Values Survey
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6 & demaut==1, nested save(prq_tableB9.doc) dec(2)
estat ic
*democracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6 & demaut==1, nested save(prq_tableB9.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB2f.gph)
estat ic


*autocracies only - model 1: no interaction effect, Afrobarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1 & demaut==0, nested save(prq_tableB10.doc) reset dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==1 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3a.gph)
estat ic

*autocracies only - model 1: no interaction effect, AmericasBarometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2 & demaut==0, nested save(prq_tableB10.doc) dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==2 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3b.gph)
estat ic

*autocracies only - model 1: no interaction effect, Arab Barometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==3 & demaut==0, nested save(prq_tableB10.doc) dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==3 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3c.gph)
estat ic

*autocracies only - model 1: no interaction effect, Asian Barometer
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4 & demaut==0, nested save(prq_tableB10.doc) dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==4 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3d.gph)
estat ic

*autocracies only - model 1: no interaction effect, Latinobarometro
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5 & demaut==0, nested save(prq_tableB10.doc) dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==5 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3e.gph)
estat ic

*autocracies only - model 1: no interaction effect, World Values Survey
asdoc mixed trust auth1 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6 & demaut==0, nested save(prq_tableB10.doc) dec(2)
estat ic
*autocracies only - model 2: interaction pvo x dpe
asdoc mixed trust c.auth1##c.dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: , cov(unstruct) , vce(robust) if survey==6 & demaut==0, nested save(prq_tableB10.doc) dec(2)
margins, dydx(auth1) at (dpe2=(0 (0.1) 1)) vsquish
marginsplot, x(dpe2)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("perceptions of democratic quality") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB3f.gph)
estat ic


**robustness check 5: standard model with only FH OR V-Dem, not the combined measure (model 3)
*combined data - model 3
asdoc mixed trust c.auth1##c.fh01 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust), nested save(prq_tableB11.doc) reset dec(2)
margins, dydx(auth1) at (fh01=(0 (0.1) 1)) vsquish
marginsplot, x(fh01)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - FH") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4a.gph)
estat ic
asdoc mixed trust c.auth1##c.v2x_libdem dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust), nested save(prq_tableB11.doc) dec(2)
margins, dydx(auth1) at (v2x_libdem=(0 (0.1) 1)) vsquish
marginsplot, x(v2x_libdem)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - V-Dem") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4b.gph)
estat ic

*democracies only - model 3
asdoc mixed trust c.auth1##c.fh01 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==1, nested save(prq_tableB11.doc) dec(2)
margins, dydx(auth1) at (fh01=(0 (0.1) 1)) vsquish
marginsplot, x(fh01)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - FH") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4c.gph)
estat ic
asdoc mixed trust c.auth1##c.v2x_libdem dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==1, nested save(prq_tableB11.doc) dec(2)
margins, dydx(auth1) at (v2x_libdem=(0 (0.1) 1)) vsquish
marginsplot, x(v2x_libdem)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - V-Dem") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4d.gph)
estat ic

*autocracies only - model 3
asdoc mixed trust c.auth1##c.fh01 dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==0, nested save(prq_tableB11.doc) dec(2)
margins, dydx(auth1) at (fh01=(0 (0.1) 1)) vsquish
marginsplot, x(fh01)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - FH") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4e.gph)
estat ic
asdoc mixed trust c.auth1##c.v2x_libdem dpe2 soctrust spe1 polint status3 i.edulevel employed i.religion reli female age || country: auth1, cov(unstruct) , vce(robust) if demaut==0, nested save(prq_tableB11.doc) dec(2)
margins, dydx(auth1) at (v2x_libdem=(0 (0.1) 1)) vsquish
marginsplot, x(v2x_libdem)
marginsplot, plot1opts(lp(solid) lc(gs1)) ci1opts(lp(dash) lc(gs6)) graphregion(color(white)) title("") subtitle("") xtitle("level of democracy - V-Dem") ///
ytitle("effects of democratic value orientations on political trust") nolabels recast(line) recastci(rline) yline(0) saving(figureB4f.gph)
estat ic




